package com.zh.oes.code;

import java.util.concurrent.Future;
import java.util.concurrent.FutureTask;
import java.util.concurrent.TimeUnit;

public class ThreadDemo {
    public static void main(String[] args) {
        Thread t1 = new Thread(() -> {
            System.out.println(Thread.currentThread().getName()+"是：\t"
                    +(Thread.currentThread().isDaemon()?"守护线程":"用户线程"));
                    while(true)
                    {}
        }, "t1");
        t1.setDaemon(true);
        t1.start();

        //暂停几秒钟线程
        try { TimeUnit.SECONDS.sleep(2); } catch (InterruptedException e) { e.printStackTrace(); }
        System.out.println(Thread.currentThread().getName()+"\t"+" ----task is over");
    }
}
